package com.nbsaas.boot.shopping.rest.resource;

import com.nbsaas.boot.shopping.api.apis.ShoppingCartApi;
import com.nbsaas.boot.shopping.data.entity.ShoppingCart;
import com.nbsaas.boot.shopping.api.domain.request.ShoppingCartRequest;
import com.nbsaas.boot.shopping.api.domain.response.ShoppingCartResponse;
import com.nbsaas.boot.shopping.api.domain.simple.ShoppingCartSimple;
import com.nbsaas.boot.shopping.rest.convert.ShoppingCartSimpleConvert;
import com.nbsaas.boot.shopping.rest.convert.ShoppingCartEntityConvert;
import com.nbsaas.boot.shopping.rest.convert.ShoppingCartResponseConvert;
import com.nbsaas.boot.shopping.data.repository.ShoppingCartRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   购物车-业务接口实现
*/
@Transactional
@Service
public class ShoppingCartResource extends BaseResource<ShoppingCart,ShoppingCartResponse, ShoppingCartSimple, ShoppingCartRequest>  implements ShoppingCartApi {

    @Resource
    private ShoppingCartRepository shoppingCartRepository;

    @Override
    public JpaRepositoryImplementation<ShoppingCart, Serializable> getJpaRepository() {
        return shoppingCartRepository;
    }

    @Override
    public Function<ShoppingCart, ShoppingCartSimple> getConvertSimple() {
        return new ShoppingCartSimpleConvert();
    }

    @Override
    public Function<ShoppingCartRequest, ShoppingCart> getConvertForm() {
        return new ShoppingCartEntityConvert();
    }

    @Override
    public Function<ShoppingCart, ShoppingCartResponse> getConvertResponse() {
        return new ShoppingCartResponseConvert();
    }




}


